package cn.efunbox.afw.data.redis.serialize;

import org.springframework.core.serializer.support.DeserializingConverter;

/**
 * Created by Dreampie on 16/9/1.
 */
public class DeserializingPrefixConverter extends DeserializingConverter {

  private byte[] prefix;

  public DeserializingPrefixConverter(byte[] prefix) {
    this.prefix = prefix;
  }

  public Object convert(byte[] prefixedKey) {
    byte[] rawKey = new byte[prefixedKey.length - prefix.length];
    System.arraycopy(prefixedKey, prefix.length, rawKey, 0, rawKey.length);
    return super.convert(rawKey);
  }
}
